import React from 'react';
import { NextComposed as Link } from '../Link'
import { useRouter } from 'next/router'
import { Pagination, PaginationItem } from '@material-ui/lab';

export default function PaginationLink({ total }) {
  const router = useRouter()
  const { query: { page = 1 } } = router
  return (
    <Pagination page={Number(page)} count={Math.ceil(total / 10)} renderItem={item => {
      return <PaginationItem component={Link} href={`/page/${item.page}`} {...item} />
    }} />
  );
}

